3 research outputs found

    Reaching for the Star: Tale of a Monad in Coq

    Get PDF
    Monadic programming is an essential component in the toolbox of functional programmers. For the pure and total programmers, who sometimes navigate the waters of certified programming in type theory, it is the only means to concisely implement the imperative traits of certain algorithms. Monads open up a portal to the imperative world, all that from the comfort of the functional world. The trend towards certified programming within type theory begs the question of reasoning about such programs. Effectful programs being encoded as pure programs in the host type theory, we can readily manipulate these objects through their encoding. In this article, we pursue the idea, popularized by Maillard [Kenji Maillard, 2019], that every monad deserves a dedicated program logic and that, consequently, a proof over a monadic program ought to take place within a Floyd-Hoare logic built for the occasion. We illustrate this vision through a case study on the SimplExpr module of CompCert [Xavier Leroy, 2009], using a separation logic tailored to reason about the freshness of a monadic gensym

    Programmes avec effets et leurs preuves dans la théorie des types : application à la compilation certifiée et aux traitements de paquets certifiés

    No full text
    One way to reason about our programs is to write them directly into a proof assistant. Using the Curry-Howard correspondence, programs and proofs are then one. In order not to undermine the logical consistency of the proof assistant, the system is forced to restrict the programs to have no side effects. However, side effects are ubiquitous and essential in programming. Different techniques such as monads or algebraic effects have emerged to model them, thus offering a way to write imperative programs in purely functional languages. It is therefore quite natural that the results of decades of research invested in reasoning about imperative programs try to be adapted to reasoning about programs with effects. In this thesis, we are first interested in the use of separation logic to reason about programs with effects implemented in a proof assistant. We study an approach to describe the behaviour of effects using a predicate transformer. We focus first on freshness, then on packet processing and zero-copy. To study our approach, we rely on two concrete examples which are the SimplExpr module of CompCert and the decoder library Nom. Finally, in order to compile the packet parsers produced to C, we propose a refinement method removing the continuations introduced by the use of a free monad and performing some optimizations.Pour pouvoir raisonner sur nos programmes, une méthode est de directement les écrire dans un assistant de preuve. Utilisant la correspondance de Curry-Howard, les programmes et les preuves ne font alors qu’un. Pour ne pas nuire à la cohérence logique de l’assistant de preuve, le système est obligé de restreindre les programmes à ne pas avoir d’effets de bord. Cependant, les effets de bord sont omniprésents et essentiels dans la programmation. Différentes techniques telles que les monades ou les effets algébriques ont alors émergé pour les modéliser offrant ainsi un moyen d'écrire des programmes impératifs dans des langages purement fonctionnels. C'est donc assez naturellement que les résultats de décennies de recherches investies pour raisonner sur des programmes impératifs tentent d'être adaptés au raisonnement sur des programmes avec effets. Dans cette thèse, nous nous intéressons d'abord à l'utilisation de la logique de séparation pour raisonner sur des programmes avec effets implémentés dans un assistant de preuve. Nous étudions une approche consistant à décrire les comportements des effets à l'aide d'un transformateur de prédicats. Nous nous concentrons d'abord sur la fraîcheur, puis sur le traitement de paquets et le zéro-copie. Pour étudier notre approche, nous nous appuyons sur deux exemples concrets qui sont le module SimplExpr de CompCert et la bibliothèque de décodeur Nom. Pour finir, pour compiler les analyseurs de paquets produits vers C, nous proposons une méthode par raffinement supprimant les continuations introduites par l'utilisation d'une monade libre et effectuant quelques optimisations

    Programmes avec effets et leurs preuves dans la théorie des types : application à la compilation certifiée et aux traitements de paquets certifiés

    No full text
    Pour pouvoir raisonner sur nos programmes, une méthode est de directement les écrire dans un assistant de preuve. Utilisant la correspondance de Curry-Howard, les programmes et les preuves ne font alors qu’un. Pour ne pas nuire à la cohérence logique de l’assistant de preuve, le système est obligé de restreindre les programmes à ne pas avoir d’effets de bord. Cependant, les effets de bord sont omniprésents et essentiels dans la programmation. Différentes techniques telles que les monades ou les effets algébriques ont alors émergé pour les modéliser offrant ainsi un moyen d'écrire des programmes impératifs dans des langages purement fonctionnels. C'est donc assez naturellement que les résultats de décennies de recherches investies pour raisonner sur des programmes impératifs tentent d'être adaptés au raisonnement sur des programmes avec effets. Dans cette thèse, nous nous intéressons d'abord à l'utilisation de la logique de séparation pour raisonner sur des programmes avec effets implémentés dans un assistant de preuve. Nous étudions une approche consistant à décrire les comportements des effets à l'aide d'un transformateur de prédicats. Nous nous concentrons d'abord sur la fraîcheur, puis sur le traitement de paquets et le zéro-copie. Pour étudier notre approche, nous nous appuyons sur deux exemples concrets qui sont le module SimplExpr de CompCert et la bibliothèque de décodeur Nom. Pour finir, pour compiler les analyseurs de paquets produits vers C, nous proposons une méthode par raffinement supprimant les continuations introduites par l'utilisation d'une monade libre et effectuant quelques optimisations.One way to reason about our programs is to write them directly into a proof assistant. Using the Curry-Howard correspondence, programs and proofs are then one. In order not to undermine the logical consistency of the proof assistant, the system is forced to restrict the programs to have no side effects. However, side effects are ubiquitous and essential in programming. Different techniques such as monads or algebraic effects have emerged to model them, thus offering a way to write imperative programs in purely functional languages. It is therefore quite natural that the results of decades of research invested in reasoning about imperative programs try to be adapted to reasoning about programs with effects. In this thesis, we are first interested in the use of separation logic to reason about programs with effects implemented in a proof assistant. We study an approach to describe the behaviour of effects using a predicate transformer. We focus first on freshness, then on packet processing and zero-copy. To study our approach, we rely on two concrete examples which are the SimplExpr module of CompCert and the decoder library Nom. Finally, in order to compile the packet parsers produced to C, we propose a refinement method removing the continuations introduced by the use of a free monad and performing some optimizations
    corecore